# -*- coding: utf-8 -*-
# Author zwhset

import conf
from datetime import datetime

# Define Log type
ERROR = "ERROR"
WARNING = "WARNING"
INFO = "INFO"

_log_file = conf.LOG_FILE
_log_format = conf.LOG_FORMAT


def log_write(module, function, type , message):
    '''Write log'''
    with open(_log_file, 'a') as fd:
        try:
            data = _log_format.format(time=datetime.today(),
                                     type=type,
                                     module=module,
                                     function=function,
                                     message=message)
            fd.write(data)
        except Exception as e:
            pass

